//
// Created by ASUS on 2024/2/5.
//
#include <bits/stdc++.h>

using namespace std;

vector<int> getz(string s){
	int n=s.length();
	vector<int> z(n);
	//z[0]=n;
	int l=0,r=0;
	for(int i=1;i<n;i++){
		if(i<=r) z[i]=min(z[i-l],r-i+1);
		while(i+z[i]<n&&s[z[i]]==s[i+z[i]]) {
			l=i;
			r=i+z[i];
			z[i]++;
		}
	}
	return z;
}

int main(){
	auto res= getz("abcbabcd");
	return 0;
}